package com.qijian.maindata.domain.vo;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.ToString;

import java.math.BigDecimal;
import java.util.List;

/**
 * 项目对象
 *
 * @author qijian
 * @date 2021-10-06
 */

@Data
@ToString
public class ProjectQualityReportVo {
    @JsonSerialize(using = ToStringSerializer.class)
    private Long projectId;

    private String projectMachineNo;

    private String projectName;

    private List<String> insType;

    private List<InsDetail> insDetails;
}

@Data
class InsDetail {
    // 检验类型
    private String insType;
    // 计划数量
    private BigDecimal insCnt;
    // 检验数量
    private BigDecimal processCnt;
    // 检验进度
    private BigDecimal processRate;

    public BigDecimal getProcessRate() {

        if (null != insCnt) {

            return processCnt.divide(insCnt, 4, BigDecimal.ROUND_HALF_UP);
        }
        return null;
    }
}